<!DOCTYPE HTML>
<html>
<head>
    <include file="Include:meta"/>
    <title>运营周报管理-目的地运营集团数据管理平台</title>
    <include file="Include:style"/>
</head>
<body>
<include file="Include:header"/>
<include file="Include:left"/>
<div id="main">
    <div class="crumbs">
        <div class="crumbs-text">运营管理 > 运营周报管理</div>
        <div class="right">
        </div>
    </div>
    <div id="content">
        <div class="table-scrollx">
            <table class="table table-bordered table-hover">
                <tr class="table-header fixed-table-header">
                    <td width="300">
                        周期
                        <select name="year" class="form-control w100">
                            <option value=""
                            <if condition="$year eq null"> selected</if>
                            >年下拉 </option>
                            <foreach name="year_list" item="vo">
                                <option value="{$vo}"
                                <if condition="$year eq $vo"> selected</if>
                                >{$vo}</option>
                            </foreach>
                        </select>
                        <select name="week" class="form-control w100">
                            <option value=""
                            <if condition="$week eq null"> selected</if>
                            >周期下拉 </option>
                            <for start="1" end="$whole_week" comparison="elt">
                                <option value="{$i}"
                                <if condition="$week eq $i">selected</if>
                                >第{$i}周</option>
                            </for>
                        </select>
                    </td>
                    <td width="300">
                        <select name="pid" class="form-control w300">
                            <option value=""
                            <if condition="$pid eq null"> selected</if>
                            >项目编号-项目名称 </option>
                            <foreach name="res_projects_all" item="vo">
                                <option value="{$vo['pid']}"
                                <if condition="$pid eq $vo['pid']"> selected</if>
                                >{$vo['project_num']}-{$vo['project_name']}</option>
                            </foreach>
                        </select>
                    </td>
                    <td width="300">本周主要工作</td>
                    <td width="300">下周计划</td>
                    <td width="300">问题描述</td>
                    <td width="200">附件</td>
                    <td width="150">
                        <select name="add_uid" class="form-control w100">
                            <option value=""
                            <if condition="$add_uid eq null"> selected</if>
                            >汇报人 </option>
                            <foreach name="add_users" item="vo">
                                <option value="{$vo}"
                                <if condition="$add_uid eq $vo"> selected</if>
                                >{:get_userName($vo)}</option>
                            </foreach>
                        </select>
                    </td>
                    <if condition="is_permission('ZB',NULL,1)">
                        <td width="80">操作</td>
                    </if>
                </tr>
                <if condition="$result eq NULL">
                    <tr>
                        <td class='text-center'
                        <if condition="is_permission('ZB',NULL,1)">colspan="6"
                            <else/>
                            colspan="5"
                        </if>
                        >暂无相关内容</td></tr>
                </if>
                <foreach name="result" item="vo">
                    <tr>
                        <td>{$vo['year']}年&nbsp;{$vo['year_week']}</a></td>
                        <td>{$vo['project_num']}-{$vo['project_name']}</td>
                        <td>{$vo['tswk']}</td>
                        <td>{$vo['nxwk']}</td>
                        <td>{$vo['description']}</td>
                        <td>
                            <if condition="$vo['file_url'] neq NULL">{$vo['file_name']}
                                <a href="{$vo['file_url']}" class="ml5" data-toggle="tooltip" target="_blank"
                                   data-placement="right" title="下载"><i class="glyphicon glyphicon-download-alt"></i>
                                </a>
                            </if>
                        </td>
                        <td>{$vo['add_user']}({$vo['add_date']|substr=0,10})</td>
                        <if condition="is_permission('ZB',NULL,1)">
                            <td>
                                <if condition="$vo['reply'] eq 1">
                                    <a href="javascript:;" weekly_id="{$vo['weekly_id']}" class="audit">批复</a>
                                </if>
                            </td>
                        </if>
                    </tr>
                </foreach>
            </table>
        </div>
        <div class="pages">{$page}</div>
    </div>
</div>
<!--批复弹框-->
<div class="modal fade" id="edit-modal">
    <div class="modal-dialog w600">
        <div class="modal-content">
            <div class="modal-header">
                <h4></h4>
                <i class="fa fa-times" aria-hidden="true" data-dismiss="modal"></i>
            </div>
            <div class="modal-body" style="line-height:30px;">
                <table class="table table-bordered">
                    <tr>
                        <td class="text-right" width="74"><strong><span class="asterisk">*</span>批复意见</strong></td>
                        <td>
                            <textarea name="reply_content" class="form-control required-text"
                                      style="width:100%; height:150px" autocomplete="off">11</textarea>
                            <span class="error-item">必填项</span>
                        </td>
                    </tr>
                </table>
            </div>
            <div class="modal-footer">
                <button type="button" class="btn btn-affirm-yes">已阅</button>
                <button type="button" class="btn btn-affirm">确认</button>
                <button type="button" class="btn btn-default" data-dismiss="modal">取消</button>
            </div>
        </div>
    </div>
</div>
<include file="Include:javascript"/>
<script type="text/javascript">
    $(function () {
        //搜索
        $(document).on("change", "[name='week']", function () {
            var week = $(this).val();
            window.location.href = "__APP__/CrmProjects/weekly_reply/year/{$year}/week/" + week;
        });
        $(document).on("change", "[name='year']", function () {
            var year = $(this).val();
            window.location.href = "__APP__/CrmProjects/weekly_reply/year/" + year;
        });
        $(document).on("change", "[name='add_uid']", function () {
            var add_uid = $(this).val();
            window.location.href = "__APP__/CrmProjects/weekly_reply/add_uid/" + add_uid;
        });
        $(document).on("change", "[name='pid']", function () {
            var pid = $(this).val();
            window.location.href = "__APP__/CrmProjects/weekly_reply/pid/" + pid;
        });
        //添加
        $(".audit").on("click", function () {
            var modal = $("#edit-modal"),
                weekly_id = $(this).attr("weekly_id");
            modal.find(".modal-header h4").text("批复");
            modal.find(".btn-affirm").attr({"weekly_id": weekly_id});
            modal.find(".btn-affirm-yes").attr({"weekly_id": weekly_id});
            modal.modal();
            modal.find("textarea").val('');
        });
        //取消
        $("#edit-modal").on('hidden.bs.modal', function () {
            $(this).find(".error-item").hide();
        });
        //审核&弃审
        $("#edit-modal").find(".btn-affirm").on("click", function () {
            var tag = false;
            $(".required-text").each(function () {
                var val = $(this).val();
                if (val == "" || /^\s+$/.test(val)) {
                    $(this).next(".error-item").show();
                    tag = true;
                }
            });
            if (tag) {
                return false;
            } else {
                var weekly_id = $(this).attr("weekly_id"),
                    reply_content = $("[name='reply_content']").val(),
                    modal = $("#edit-modal");
                modal.hide();
                $.ajax({
                    type: "POST",
                    async: false,
                    dataType: "json",
                    data: {"weekly_id": weekly_id, "reply_content": reply_content},
                    url: "__APP__/CrmProjects/weekly_reply_ajax",
                    success: function (data) {
                        if (data.status) {
                            success_pop(data['status'], data['msg']);
                        } else {
                            defeated_alert(data.msg);
                        }
                    }
                });
            }
        });
        $("#edit-modal").find(".btn-affirm-yes").on("click", function () {
            var weekly_id = $(this).attr("weekly_id"),
                modal = $("#edit-modal");
            modal.hide();
            $.ajax({
                type: "POST",
                async: false,
                dataType: "json",
                data: {"weekly_id": weekly_id},
                url: "__APP__/CrmProjects/weekly_reply_ajax",
                success: function (data) {
                    if (data.status) {
                        success_pop(data['status'], data['msg']);
                    } else {
                        defeated_alert(data.msg);
                    }
                }
            });
        });
        $(document).on("focus", ".required-text", function () {
            $(this).nextAll(".error-item").hide();
        });
    });
</script>
</body>
</html>